<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app"></div>
    <template id="t1">
      <div>
        <h2
          style="
            color: red;
            font-size: 3rem;
            border: solid;
            background-color: yellow;
          "
        >
          hello title
        </h2>

        <h2
          :style="{color,fontSize:'3rem',border:'solid',backgroundColor:'yellow'}"
        >
          hello title
        </h2>

        <h2 :style="styleObj">hello title</h2>
      </div>
    </template>
    <script src="./vue.js"></script>
    <script>
      // 数据驱动视图
      const vm = new Vue({
        el: "#app",
        template: "#t1",
        data: {
          color: "red",
          styleObj: {
            color: "red",
            fontSize: "3rem",
            border: "solid",
            backgroundColor: "yellow",
          },
        },
        created() {
          setTimeout(() => {
            this.color = "green";
            this.styleObj.backgroundColor = "green";
          }, 3000);
        },
      });
    </script>
  </body>
</html>
